package com.sugon.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.ModuleTimesSynNoticeDao;
import com.sugon.entity.ModuleTimesSynNoticeEntity;
import com.sugon.service.ModuleTimesSynNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 模次同步通知，用于模具换件后通知程序同步模次Service实现类
 *
 * @author YuXD
 * @date 2020-11-13 10:27
 */
@Service("moduleTimesSynNoticeService")
public class ModuleTimesSynNoticeServiceImpl implements ModuleTimesSynNoticeService {

    @Autowired
    private ModuleTimesSynNoticeDao moduleTimesSynNoticeDao;

    @Override
    public ModuleTimesSynNoticeEntity queryObject(String id) {
        return moduleTimesSynNoticeDao.queryObject(id);
    }

    @Override
    public List<ModuleTimesSynNoticeEntity> queryList(Map<String, Object> map) {
        return moduleTimesSynNoticeDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return moduleTimesSynNoticeDao.queryTotal(map);
    }

    @Override
    public int save(ModuleTimesSynNoticeEntity moduleTimesSynNotice) {
        moduleTimesSynNotice.setId(RandomUtil.randomString(32));
        moduleTimesSynNotice.setGmtCreate(DateUtil.date());
        moduleTimesSynNotice.setGmtModified(moduleTimesSynNotice.getGmtCreate());
        moduleTimesSynNotice.setIsHandled(0);
        return moduleTimesSynNoticeDao.save(moduleTimesSynNotice);
    }

    @Override
    public int update(ModuleTimesSynNoticeEntity moduleTimesSynNotice) {
        moduleTimesSynNotice.setGmtModified(DateUtil.date());
        return moduleTimesSynNoticeDao.update(moduleTimesSynNotice);
    }

    @Override
    public int delete(String id) {
        return moduleTimesSynNoticeDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return moduleTimesSynNoticeDao.deleteBatch(ids);
    }

}
